COMPILER = ghc
FLAGS = 
BIN_DIR = bin
FLAGS= 
BIN_DIR:=bin
SRC_DIR:=src
CUR_DIR:=$(shell echo $(PWD))
GLADEFILE:=vncconfig.glade
BINFILE:=vncconfig-gui

all : $(CUR_DIR)/$(SRC_DIR)/*.hs
	cd $(CUR_DIR)/$(SRC_DIR) && $(COMPILER) --make -o vncconfig-gui $(FLAGS) maingui.hs -v Fileutils.hs && mv $(CUR_DIR)/$(SRC_DIR)/vncconfig-gui $(CUR_DIR)/$(BIN_DIR) && cp $(CUR_DIR)/$(SRC_DIR)/vncconfig.glade $(CUR_DIR)/$(BIN_DIR)

.PHONY:bin glade make_dir

.PHONY:
install : make_dir bin glade
	@echo "Installation Complete!"

.PHONY:
make_dir :
	@if [ -d $$HOME/bin ]; then echo $$HOME/bin exists; else echo \"Creating bin directory in HOME folder\" && mkdir $$HOME/bin ;fi

.PHONY:
bin :
	@echo "Copying $(BINFILE) binary into bin folder"
	cd $(BIN_DIR) && cp $(BINFILE) $$HOME/bin

.PHONY:
glade :
	@echo "Copying glade file into bin folder"
	cd $(BIN_DIR) && cp $(GLADEFILE) $$HOME/bin
	@echo "The GUI won't work without this file :).Do not remove it from bin directory"

.PHONY:
clean :
	cd $(SRC_DIR) && rm -rf *.hi &&	rm -rf *.o
	cd $(BIN_DIR) && rm $(BINFILE) && rm $(GLADEFILE)
		
